import data from '../data/emoji-data.js'
import data2 from '../data/config.js'
let emojiData = {}
Object.values(data).forEach(item => {
  emojiData = { ...emojiData, ...item }
})
let emojiData2 = {}
Object.values(data2).forEach(item => {
  emojiData2 = { ...emojiData2, ...item }
})

/**
 *
 *
 * @export
 * @param {string} value
 * @returns {string}
 */

export function emoji (value) {
  if (!value) return
  Object.keys(emojiData2).forEach(item => {
    value = value.replace(new RegExp(item, 'g'), createIcon(item))
    // console.log(value)
  })
  return value
}

function createIcon (item) {
  const value = emojiData2[item]
  // console.log('value', value)
  return value
  // const path = '../static/emoji/'
  // return `<img src=${path}${value} width="16px" height="16px" style="margin:0 1.5px;" >`
}
